from django.contrib import admin
from .models import Post, Comment
# Register your models here.

class PostAdmin(admin.ModelAdmin):
    '''定制mdoels的展现形式'''
    #指定展示的列名
    list_display = ('id', 'title', 'slug', 'author', 'publish', 'status')
    #filter过滤器，指定字段进行过滤
    list_filter = ('status', 'created', 'publish', 'author')
    #查询条件
    search_fields = ('title', 'body')
    prepopulated_fields = {'slug': ('title',)}
    raw_id_fields = ('author',)
    date_hirearchy = 'pubilsh'
    ordering = ['status', 'publish']

class CommentAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'email', 'post', 'created', 'active')
    list_filter = ('active', 'created', 'updated')
    search_fields = ('name', 'email', 'body')


admin.site.register(Post, PostAdmin)
admin.site.register(Comment, CommentAdmin)
